package main

import "log"

/*工厂模式*/
func main() {
	log.Println(GetFruitsFactoryWorkshop("orange").NewFruits())
	log.Println(GetFruitsFactoryWorkshop("apple").NewFruits())
}

func GetFruitsFactoryWorkshop(need string) FruitsFactory {
	switch need {
	case "orange":
		return new(OrangeWorkshop)
	case "apple":
		return new(AppleWorkshop)
	default:
		return nil
	}
}

type FruitsFactory interface {
	NewFruits() string
}

type AppleWorkshop struct {
}

func (f *AppleWorkshop) NewFruits() string {
	return "苹果"
}

type OrangeWorkshop struct {
}

func (f *OrangeWorkshop) NewFruits() string {
	return "橘子"
}
